package com.kgcx.organization.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.kgcx.common.bean.RequestData;
import com.kgcx.common.constant.Cons;
import com.kgcx.dbutils.domain.BaseDomain;
import com.kgcx.dbutils.utils.PageUtils;
import com.kgcx.organization.domain.AirportParking;
import com.kgcx.organization.mapper.AirportParkingMapper;

@Service
public class AirportParkingService {
    @Autowired
    private AirportParkingMapper airportParkingMapper;

    public AirportParking getAirportParking(Long kid) {
        return airportParkingMapper.selectByPrimaryKey(kid);
    }

    public List<AirportParking> getAirportParkingList(RequestData rd) {
        PageUtils.page(rd);
        PageHelper.orderBy(rd.getOrderBy());
        return airportParkingMapper.getAirportParking(BaseDomain.buildSelectDomain(rd, new AirportParking()));
    }

    @Transactional(rollbackFor = Exception.class)
    public void addAirportParking(AirportParking airportParking) {
        airportParkingMapper.insertSelective(airportParking);
    }

    @Transactional(rollbackFor = Exception.class)
    public void updateAirportParking(AirportParking airportParking) {
        airportParkingMapper.updateByPrimaryKeySelective(airportParking);
    }

    @Transactional(rollbackFor = Exception.class)
    public void removeAirportParking(Long kid) {
        AirportParking airportParking = new AirportParking();
        airportParking.setKid(kid);
        airportParking.setStatus(Cons.COMMON_STATUS_DELETE);
        airportParkingMapper.updateByPrimaryKeySelective(airportParking);
    }
}
